/*
 * @Descripttion: 
 * @version: 
 * @Author: 刘冰见
 * @Date: 2024-10-09 08:54:43
 * @LastEditors: 刘冰见
 * @LastEditTime: 2024-10-12 13:14:17
 */
import 'package:dio/dio.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:sousuoapp/net/method/bese_method.dart';
import 'package:sousuoapp/net/network_manager.dart';
import 'package:sousuoapp/net/response/base_response.dart';

class LoginController {
  final CancelToken _cancelToken = CancelToken();
  getPublicKey() async {
    BaseResponse response = await NetworkManager()
        .request('user/public_key', method: BaseMethod.get);
    if (response.code == 200) {
      return response.data;
    } else {
      EasyLoading.dismiss();
    }
  }

  loginIn(data) async {
    BaseResponse response = await NetworkManager().request('/user/login',
        method: BaseMethod.post, cancelToken: _cancelToken, data: data);
    if (response.code == 200) {
      return response.data;
    } else {
      EasyLoading.dismiss();
    }
  }
}
